#ifndef __CAN_CONFIG_H__
#define __CAN_CONFIG_H__
#include "can_test.h"

void config_can_level_quality(void *param) {
    struct can_param_t *pparam = param;
    uint8_t i = 0;

    if (pparam->read_cnt == 0)
        pparam->read_cnt = 1;
    if (pparam->write_cnt == 0)
        pparam->write_cnt = 1;

    pparam->en_read = 1;
    pparam->read_cnt = -1;
    pparam->en_write = 1;
    pparam->write_cnt = 5;
    pparam->delay_ms = 0;

    for (i = 0; i < pparam->dev_num; i++) {
        pparam->dev[i].index = i;

        if (pparam->dev[i].msg_type_cnt == 0)
            pparam->dev[i].msg_type_cnt = 1;

        if (pparam->dev[i].baud_rate_cnt == 0) {
            pparam->dev[i].baud_rate_cnt = 1;
            pparam->dev[i].arbitration_baud[0].bitrate = 1000000;
            pparam->dev[i].arbitration_baud[0].sample_point = 750;
            pparam->dev[i].arbitration_baud[0].sjw = 1;
        }

        pparam->dev[i].msg_type_cnt = 1;
        pparam->dev[i].msg[0] = (struct can_msg_t){
            .fmt = 1,
            .rtr = 0,
            .id = 0x15A5A5A5,
            .dlc = 8,
            .flg = 0,
            .data = {0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA}
        };
        pparam->dev[i].msg[1] = (struct can_msg_t){
            .fmt = 1,
            .rtr = 0,
            .id = 0x1A5A5A5A,
            .dlc = 8,
            .flg = 0,
            .data = {0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55}
        };
        pparam->dev[i].msg[2] = (struct can_msg_t){
            .fmt = 0,
            .rtr = 0,
            .id = 0x75A,
            .dlc = 8,
            .flg = 0,
            .data = {0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA}
        };
    }
}

#endif /* __CAN_CONFIG_H__ */
